package com.haoshuang.zhouzhoubang.ui.dialog

import android.content.Context
import com.haoshuang.zhouzhoubang.R
import com.haoshuang.zhouzhoubang.databinding.DialogUploadWriteOffCodeBinding
import com.lxj.xpopup.core.CenterPopupView
import com.mufeng.libs.utils.view.clickWithTrigger
import com.mufeng.libs.utils.view.visibleOrGone

/**
 * 上传核销码
 * @property content String
 * @property isHideCancel Boolean
 * @property onUpload Function0<Unit>
 * @property binding DialogUploadWriteOffCodeBinding
 * @constructor
 */
class UploadWriteOffCodeDialog(
    context: Context,
    private val content: String,
    private val isHideCancel: Boolean = false,
    private val onUpload: () -> Unit,
) :
    CenterPopupView(context) {

    private lateinit var binding: DialogUploadWriteOffCodeBinding

    override fun getImplLayoutId(): Int {
        return R.layout.dialog_upload_write_off_code
    }

    override fun onCreate() {
        super.onCreate()
        binding = DialogUploadWriteOffCodeBinding.bind(popupImplView)

        binding.tvContent.text = content
        binding.tvCancel.visibleOrGone(!isHideCancel)
        binding.tvCancel.clickWithTrigger {
            dismiss()
        }

        binding.tvConfirm.clickWithTrigger {
            dismiss()
            onUpload()
        }
    }


}